package com.infra.micro.oss.fallback;

import com.infra.common.resp.PageEx;
import com.infra.common.resp.Response;
import com.infra.micro.oss.api.OssBizInfoApi;
import com.infra.micro.oss.model.req.QueryBizInfoReq;
import com.infra.micro.oss.model.vo.BizFileVO;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

public class OssBizInfoApiFallback implements FallbackFactory<OssBizInfoApi> {
    @Override
    public OssBizInfoApi create(Throwable cause) {
        return new OssBizInfoApi() {
            @Override
            public Response<BizFileVO> queryByBizId(Long bizId) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }

            @Override
            public Response<List<BizFileVO>> queryByBizIds(List<Long> bizIds) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }

            @Override
            public Response<Boolean> deleteByBizId(Long bizId) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }

            @Override
            public Response<Boolean> deleteByBizIds(List<Long> bizIds) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }

            @Override
            public Response<PageEx<BizFileVO, QueryBizInfoReq>> queryByPage(QueryBizInfoReq req) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }
        };
    }
}
